package edu.spbu.eclipse.xmledit.golubevhritoshin.editors;

import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.editors.text.TextEditor;

public class SXEditor extends TextEditor {
	private SXESyntaxChecker checker;
	private ColorManager colorManager;

	public SXEditor() {
		super();
		colorManager = new ColorManager();
		setSourceViewerConfiguration(new XMLConfiguration(colorManager));
		setDocumentProvider(new XMLDocumentProvider());
	}

	@Override
	public void dispose() {
		colorManager.dispose();
		super.dispose();
	}

	public SXESyntaxChecker getSXESyntaxChecker() {
		return checker;
	}

	@Override
	public void init(IEditorSite site, IEditorInput input) {
		try {
			super.init(site, input);
		} catch (PartInitException e) {
			e.printStackTrace();
		}
		checker = new SXESyntaxChecker(this);
		addPropertyListener(checker);
	}
}
